package com.chrilwe.pigpig.auth.config;

import java.io.IOException;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestTemplate;

@Configuration
public class AppConfig {

	@Bean
	public RestTemplate restTemplate() {
		RestTemplate restTemplate = new RestTemplate();
		/*
		 * restTemplate.setErrorHandler(new DefaultResponseErrorHandler() {
		 * 
		 * @Override public void handleError(ClientHttpResponse response) throws
		 * IOException { HttpStatus statusCode = response.getStatusCode();
		 * if(HttpStatus.UNAUTHORIZED != statusCode) { super.handleError(response); } }
		 * 
		 * });
		 */
		return restTemplate;
	}

}
